package com.uniflow.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 权限实体类
 * 
 * @author uniflow
 * @since 1.0.0
 */
@ApiModel(description = "权限")
@TableName("permissions")
public class Permission {
    
    @ApiModelProperty("权限ID")
    private String id;
    
    @ApiModelProperty("权限代码")
    private String code;
    
    @ApiModelProperty("权限名称")
    private String name;
    
    @ApiModelProperty("权限描述")
    private String description;
    
    @ApiModelProperty("权限类型：menu-菜单权限，operation-操作权限，data-数据权限")
    private String type;
    
    @ApiModelProperty("资源标识")
    private String resource;
    
    @ApiModelProperty("操作标识")
    private String action;
    
    @ApiModelProperty("父级权限ID")
    private String parentId;
    
    @ApiModelProperty("排序顺序")
    private Integer sortOrder;
    
    @ApiModelProperty("是否启用")
    private Boolean enabled;
    
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdAt;
    
    @ApiModelProperty("更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updatedAt;
    
    // 关联查询字段
    @ApiModelProperty("父级权限")
    private Permission parent;
    
    @ApiModelProperty("子级权限列表")
    private List<Permission> children;
    
    // 构造函数
    public Permission() {}
    
    public Permission(String code, String name, String type) {
        this.code = code;
        this.name = name;
        this.type = type;
    }
    
    // Getter和Setter方法
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public String getCode() {
        return code;
    }
    
    public void setCode(String code) {
        this.code = code;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public String getType() {
        return type;
    }
    
    public void setType(String type) {
        this.type = type;
    }
    
    public String getResource() {
        return resource;
    }
    
    public void setResource(String resource) {
        this.resource = resource;
    }
    
    public String getAction() {
        return action;
    }
    
    public void setAction(String action) {
        this.action = action;
    }
    
    public String getParentId() {
        return parentId;
    }
    
    public void setParentId(String parentId) {
        this.parentId = parentId;
    }
    
    public Integer getSortOrder() {
        return sortOrder;
    }
    
    public void setSortOrder(Integer sortOrder) {
        this.sortOrder = sortOrder;
    }
    
    public Boolean getEnabled() {
        return enabled;
    }
    
    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }
    
    public LocalDateTime getCreatedAt() {
        return createdAt;
    }
    
    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }
    
    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }
    
    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }
    
    public Permission getParent() {
        return parent;
    }
    
    public void setParent(Permission parent) {
        this.parent = parent;
    }
    
    public List<Permission> getChildren() {
        return children;
    }
    
    public void setChildren(List<Permission> children) {
        this.children = children;
    }
    
    @Override
    public String toString() {
        return "Permission{" +
                "id='" + id + '\'' +
                ", code='" + code + '\'' +
                ", name='" + name + '\'' +
                ", type='" + type + '\'' +
                ", resource='" + resource + '\'' +
                ", action='" + action + '\'' +
                ", enabled=" + enabled +
                '}';
    }
}